student=(1,"王华","2009-05-06",10,133.6) # 创建元组，在小括号中添加元素，用逗号隔开
student = () # 创建空元组
student = ("王华",) # 元组只有1个元素时，需要添加逗号
print(student[0]) # 使用下标索引访问元组元素
connect = ("三年级",) + student # 元组拼接
print(connect)
del student # 删除整个元组
print(len(connect)) # 获取元组长度
print(connect*3) # 复制元组
print("王华" in connect) # 判断元素是否在元组中

for i in connect: # 遍历元组
    print(i)
for index,eachOne in enumerate(connect): # 遍历元组，同时获取索引和元素
    print(index,eachOne)
for index in range(len(connect)): # 遍历元组，同时获取索引
    print(index,connect[index])
for eachOne in iter(connect): # 遍历元组，同时获取元素
    print(eachOne,end=",")

# 元组切片截取
autoGroup = ("小明", "小红", "小刚", "小李", "小王", "小赵", "小钱", "小孙", "小周", "小吴")
print(autoGroup[2:6])
print(autoGroup[:6])
print(autoGroup[2:])
print(autoGroup[:])
print(autoGroup[-3:])
print(autoGroup[::2])
print(autoGroup[::-1])
print(autoGroup[-2])

# 求极值
autoGroup = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
print(max(autoGroup),min(autoGroup))

# 列表转元组
arr=[1,2,3,4,5]
autoGroup=tuple(arr)
print(autoGroup)

# 元组转列表
autoGroup=(1,2,3,4,5)
print(list(autoGroup))

# 字符串与列表转换
a="abcdef"
arr=list(a)
print(arr)
print(str(a),a)
print("".join(arr))
print(",".join(arr))

# 元组嵌套
autoGroup=(["张三",88,99],["李四",88,99])
print(autoGroup)
print(list(autoGroup))